//
//  MoreServicePlanViewController.m
//  MyProject
//
//  Created by 石小强 on 2018/5/8.
//  Copyright © 2018年 yanjiaming. All rights reserved.
//

#import "MoreServicePlanViewController.h"

@interface MoreServicePlanViewController ()

@property (nonatomic, strong) UIView *backV;

@end

@implementation MoreServicePlanViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"服务保障计划";
    
    [self setupSubViews];
}

- (void)doBack:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)setupSubViews {
    UIView *backV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    backV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
    self.backV = backV;
//    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(backViewOnPress)];
//    [backV addGestureRecognizer:tap];
    
    CGFloat navH = [Tool isIphoneX] ? 24 : 0;
    UIImageView *imageIV = [[UIImageView alloc] initWithFrame:CGRectMake(15, 85 + navH, kScreenWidth - 30, 958 * (kScreenWidth - 30) / 704)];
    imageIV.image = [UIImage imageNamed:@"pop_content"];
    [backV addSubview:imageIV];
    
    UIButton *closeB = [[UIButton alloc] initWithFrame:CGRectMake((kScreenWidth - 40) * 0.5, CGRectGetMaxY(imageIV.frame) + 18, 40, 40)];
    [closeB setBackgroundImage:[UIImage imageNamed:@"popMorePlanClose"] forState:UIControlStateNormal];
    [closeB addTarget:self action:@selector(backViewOnPress) forControlEvents:UIControlEventTouchUpInside];
    [backV addSubview:closeB];
    
    [[UIApplication sharedApplication].keyWindow addSubview:backV];
}

- (void)backViewOnPress {
    [self.backV removeFromSuperview];
    [self dismissViewControllerAnimated:NO completion:nil];
}

@end
